<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=9"/>
<title>TagM: RTOS::mutex Class Reference</title>
<link href="tabs.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="dynsections.js"></script>
<link href="search/search.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="search/search.js"></script>
<script type="text/javascript">
  $(document).ready(function() { searchBox.OnSelectItem(0); });
</script>
<link href="doxygen.css" rel="stylesheet" type="text/css" />
</head>
<body>
<div id="top"><!-- do not remove this div, it is closed by doxygen! -->
<div id="titlearea">
<table cellspacing="0" cellpadding="0">
 <tbody>
 <tr style="height: 56px;">
  <td style="padding-left: 0.5em;">
   <div id="projectname">TagM
   &#160;<span id="projectnumber">1.0</span>
   </div>
  </td>
 </tr>
 </tbody>
</table>
</div>
<!-- end header part -->
<!-- Generated by Doxygen 1.8.1.1 -->
<script type="text/javascript">
var searchBox = new SearchBox("searchBox", "search",false,'Search');
</script>
  <div id="navrow1" class="tabs">
    <ul class="tablist">
      <li><a href="index.html"><span>Main&#160;Page</span></a></li>
      <li><a href="pages.html"><span>Related&#160;Pages</span></a></li>
      <li class="current"><a href="annotated.html"><span>Classes</span></a></li>
      <li><a href="files.html"><span>Files</span></a></li>
      <li>
        <div id="MSearchBox" class="MSearchBoxInactive">
        <span class="left">
          <img id="MSearchSelect" src="search/mag_sel.png"
               onmouseover="return searchBox.OnSearchSelectShow()"
               onmouseout="return searchBox.OnSearchSelectHide()"
               alt=""/>
          <input type="text" id="MSearchField" value="Search" accesskey="S"
               onfocus="searchBox.OnSearchFieldFocus(true)" 
               onblur="searchBox.OnSearchFieldFocus(false)" 
               onkeyup="searchBox.OnSearchFieldChange(event)"/>
          </span><span class="right">
            <a id="MSearchClose" href="javascript:searchBox.CloseResultsWindow()"><img id="MSearchCloseImg" border="0" src="search/close.png" alt=""/></a>
          </span>
        </div>
      </li>
    </ul>
  </div>
  <div id="navrow2" class="tabs2">
    <ul class="tablist">
      <li><a href="annotated.html"><span>Class&#160;List</span></a></li>
      <li><a href="classes.html"><span>Class&#160;Index</span></a></li>
      <li><a href="hierarchy.html"><span>Class&#160;Hierarchy</span></a></li>
      <li><a href="functions.html"><span>Class&#160;Members</span></a></li>
    </ul>
  </div>
<!-- window showing the filter options -->
<div id="MSearchSelectWindow"
     onmouseover="return searchBox.OnSearchSelectShow()"
     onmouseout="return searchBox.OnSearchSelectHide()"
     onkeydown="return searchBox.OnSearchSelectKey(event)">
<a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(0)"><span class="SelectionMark">&#160;</span>All</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(1)"><span class="SelectionMark">&#160;</span>Classes</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(2)"><span class="SelectionMark">&#160;</span>Functions</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(3)"><span class="SelectionMark">&#160;</span>Variables</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(4)"><span class="SelectionMark">&#160;</span>Enumerations</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(5)"><span class="SelectionMark">&#160;</span>Friends</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(6)"><span class="SelectionMark">&#160;</span>Pages</a></div>

<!-- iframe showing the search results (closed by default) -->
<div id="MSearchResultsWindow">
<iframe src="javascript:void(0)" frameborder="0" 
        name="MSearchResults" id="MSearchResults">
</iframe>
</div>

<div id="nav-path" class="navpath">
  <ul>
<li class="navelem"><a class="el" href="class_r_t_o_s.html">RTOS</a></li><li class="navelem"><a class="el" href="class_r_t_o_s_1_1mutex.html">mutex</a></li>  </ul>
</div>
</div><!-- top -->
<div class="header">
  <div class="summary">
<a href="#pub-methods">Public Member Functions</a> &#124;
<a href="#friends">Friends</a>  </div>
  <div class="headertitle">
<div class="title">RTOS::mutex Class Reference</div>  </div>
</div><!--header-->
<div class="contents">

<p>mutual execlusion semaphore  
 <a href="class_r_t_o_s_1_1mutex.html#details">More...</a></p>

<p><code>#include &lt;<a class="el" href="p_r_t_o_s_8h_source.html">pRTOS.h</a>&gt;</code></p>

<p><a href="class_r_t_o_s_1_1mutex-members.html">List of all members.</a></p>
<table class="memberdecls">
<tr class="heading"><td colspan="2"><h2><a name="pub-methods"></a>
Public Member Functions</h2></td></tr>
<tr class="memitem:a018aed6b83cf182b9990ac90a3254904"><td class="memItemLeft" align="right" valign="top">&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="class_r_t_o_s_1_1mutex.html#a018aed6b83cf182b9990ac90a3254904">mutex</a> (const char *name=&quot;&quot;)</td></tr>
<tr class="memdesc:a018aed6b83cf182b9990ac90a3254904"><td class="mdescLeft">&#160;</td><td class="mdescRight">constructor, specify the name  <a href="#a018aed6b83cf182b9990ac90a3254904"></a><br/></td></tr>
<tr class="memitem:a58255b4d832c8140f2b45efcc2065733"><td class="memItemLeft" align="right" valign="top">&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="class_r_t_o_s_1_1mutex.html#a58255b4d832c8140f2b45efcc2065733">~mutex</a> (void)</td></tr>
<tr class="memdesc:a58255b4d832c8140f2b45efcc2065733"><td class="mdescLeft">&#160;</td><td class="mdescRight">generates an error  <a href="#a58255b4d832c8140f2b45efcc2065733"></a><br/></td></tr>
<tr class="memitem:aef6201cdf6b86c532629b5888d740303"><td class="memItemLeft" align="right" valign="top"><a class="anchor" id="aef6201cdf6b86c532629b5888d740303"></a>
void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="class_r_t_o_s_1_1mutex.html#aef6201cdf6b86c532629b5888d740303">print</a> (std::ostream &amp;stream, bool header=true) const </td></tr>
<tr class="memdesc:aef6201cdf6b86c532629b5888d740303"><td class="mdescLeft">&#160;</td><td class="mdescRight">prints a mutex, for debugging only. <br/></td></tr>
<tr class="memitem:a52160d98a50d74a44fc4592a4625c6ed"><td class="memItemLeft" align="right" valign="top">void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="class_r_t_o_s_1_1mutex.html#a52160d98a50d74a44fc4592a4625c6ed">wait</a> (void)</td></tr>
<tr class="memitem:a9a6cb88e182f977bce35e024449b24cd"><td class="memItemLeft" align="right" valign="top">void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="class_r_t_o_s_1_1mutex.html#a9a6cb88e182f977bce35e024449b24cd">signal</a> (void)</td></tr>
<tr class="memdesc:a9a6cb88e182f977bce35e024449b24cd"><td class="mdescLeft">&#160;</td><td class="mdescRight">release the mutex  <a href="#a9a6cb88e182f977bce35e024449b24cd"></a><br/></td></tr>
</table><table class="memberdecls">
<tr class="heading"><td colspan="2"><h2><a name="friends"></a>
Friends</h2></td></tr>
<tr class="memitem:aa5b30b5b619f01a5d94b779bf0e58610"><td class="memItemLeft" align="right" valign="top"><a class="anchor" id="aa5b30b5b619f01a5d94b779bf0e58610"></a>
class&#160;</td><td class="memItemRight" valign="bottom"><b>RTOS</b></td></tr>
</table>
<hr/><a name="details" id="details"></a><h2>Detailed Description</h2>
<div class="textblock"><p>mutual execlusion semaphore </p>
<pre class="fragment">  A mutex (mutual exclusion semaphore) is a synchronization mechanism 
  that is used to give a task exclusive access to some resource: 
  the task can execute a sequence of statements, being sure that 
  no other task is accessing the same resource. 

  A typical use is to protect a resource (for instance global data)
  that should be used by only one task at a time, so it can update
  it and leave it in a consistent state.   

  A mutex is not created for a particular task, and it is not a waitable.

  Initially a mutex is free. 
  The mutex::wait() operation blocks the task until the mutex is free, 
  and then claims the mutex for the executing task. 
  The mutex::signal() operation frees the mutex again. 
  It is an error to call mutex::signal on a mutex that is not 
  currently owned by the executing task.

  The example below shows two tasks that write messages to the 
  LCD display. Each task writes to its own line. 
  For the demonstration, after each LCD operation a sleep() 
  is put to allow the other tasks to run. 
  A mutex prevents the other task from accessing the LCD 
  while the first one is still using it. 

  @code 
</pre><p> TBW  </p>
</div><hr/><h2>Constructor &amp; Destructor Documentation</h2>
<a class="anchor" id="a018aed6b83cf182b9990ac90a3254904"></a>
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">RTOS::mutex::mutex </td>
          <td>(</td>
          <td class="paramtype">const char *&#160;</td>
          <td class="paramname"><em>name</em> = <code>&quot;&quot;</code></td><td>)</td>
          <td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p>constructor, specify the name </p>
<p>The name is used for debugging only. </p>

</div>
</div>
<a class="anchor" id="a58255b4d832c8140f2b45efcc2065733"></a>
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">RTOS::mutex::~mutex </td>
          <td>(</td>
          <td class="paramtype">void&#160;</td>
          <td class="paramname"></td><td>)</td>
          <td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p>generates an error </p>
<p>A mutex should never be destroyed </p>

</div>
</div>
<hr/><h2>Member Function Documentation</h2>
<a class="anchor" id="a9a6cb88e182f977bce35e024449b24cd"></a>
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">void RTOS::mutex::signal </td>
          <td>(</td>
          <td class="paramtype">void&#160;</td>
          <td class="paramname"></td><td>)</td>
          <td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p>release the mutex </p>
<p>If one or more tasks are waiting for the mutex the firs one is released, and it now owns the mutex. Otherwise, if the mutex is cleared it is now set.</p>
<p>It is an error for a task to call <a class="el" href="class_r_t_o_s_1_1mutex.html#a9a6cb88e182f977bce35e024449b24cd" title="release the mutex">signal()</a> on a mutex that it does not own (that it did not call <a class="el" href="class_r_t_o_s_1_1mutex.html#a52160d98a50d74a44fc4592a4625c6ed">wait()</a> on). After the signal the task no longer owns the mutex. </p>

</div>
</div>
<a class="anchor" id="a52160d98a50d74a44fc4592a4625c6ed"></a>
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">void RTOS::mutex::wait </td>
          <td>(</td>
          <td class="paramtype">void&#160;</td>
          <td class="paramname"></td><td>)</td>
          <td></td>
        </tr>
      </table>
</div><div class="memdoc">
<p>claim the mutex</p>
<p>If the mutex was set it it is now cleared, and the calling task owns the mutex.</p>
<p>Otherwise the current task waits (is halted) until the owning task calls <a class="el" href="class_r_t_o_s_1_1mutex.html#a9a6cb88e182f977bce35e024449b24cd" title="release the mutex">signal()</a> on the same mutex. The <a class="el" href="class_r_t_o_s_1_1mutex.html#a9a6cb88e182f977bce35e024449b24cd" title="release the mutex">signal()</a> calls will release the tasks in the order of their <a class="el" href="class_r_t_o_s_1_1mutex.html#a52160d98a50d74a44fc4592a4625c6ed">wait()</a> calls. </p>

</div>
</div>
<hr/>The documentation for this class was generated from the following files:<ul>
<li><a class="el" href="p_r_t_o_s_8h_source.html">pRTOS.h</a></li>
<li>pRTOS.cpp</li>
</ul>
</div><!-- contents -->
<!-- start footer part -->
<hr class="footer"/><address class="footer"><small>
Generated on Wed Jun 27 2012 11:07:15 for TagM by &#160;<a href="http://www.doxygen.org/index.html">
<img class="footer" src="doxygen.png" alt="doxygen"/>
</a> 1.8.1.1
</small></address>
</body>
</html>
